package com.dmn.gcode.springchains.operators;

import com.dmn.gcode.springchains.Multiplicator;
import com.dmn.gcode.springchains.core.AbstractOperator;
import com.dmn.gcode.springchains.core.In;
import com.dmn.gcode.springchains.core.IChainMaster;
import com.dmn.gcode.springchains.core.Out;

/**
 * date 17.01.11
 *
 * @author dvponomarev
 * @version 1.0
 */
public class MultiplicationOperator extends AbstractOperator {
    //in
    private String description;
    private In<Double> a;
    private In<Double> b;
    private In<Multiplicator> multiplicator;

    //out
    private Out<Double> outMultiplication;
    private Out<Integer> outIntMultiplication;

    public void execute(IChainMaster chainMaster) throws Throwable {
        Double a = this.a.get();
        Double b = this.b.get();
        outMultiplication.set(multiplicator.get().mult(a, b));
        outIntMultiplication.set((int) multiplicator.get().mult(a, b));
    }

    public void setDescription(String name) {
        this.description = name;
    }

    public void setA(In<Double> a) {
        this.a = a;
    }

    public void setB(In<Double> b) {
        this.b = b;
    }

    public void setMultiplicator(In<Multiplicator> multiplicator) {
        this.multiplicator = multiplicator;
    }

    public void setOutMultiplication(Out<Double> outMultiplication) {
        this.outMultiplication = outMultiplication;
    }

    public void setOutIntMultiplication(Out<Integer> outIntMultiplication) {
        this.outIntMultiplication = outIntMultiplication;
    }
}
